/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.posplus.losspreventiondataimporter.util;

import com.posplus.lossprevention.mapping.Actions;
import com.posplus.lossprevention.mapping.Cashiers;
import com.posplus.lossprevention.mapping.Departments;
import com.posplus.lossprevention.mapping.Products;
import com.posplus.lossprevention.mapping.Registers;
import com.posplus.lossprevention.mapping.Stores;
import com.posplus.lossprevention.mapping.Transactions;
import com.posplus.lossprevention.mapping.UniqueTransaction;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author scottw
 */
public class ListToMap {
    public static Map<String, Stores> storesToMap(Collection<Stores> stores){
        Map<String, Stores> map = new HashMap<String, Stores>();
        
        Iterator<Stores> iter = stores.iterator();
        while(iter.hasNext()){
            Stores next = iter.next();
            map.put(next.getCode(), next);
        }
        
        return map;
    }
    
    public static Map<UniqueTransaction, Transactions> transactionsToMap(Collection<Transactions> transactions){
        Map<UniqueTransaction, Transactions> map = new HashMap<UniqueTransaction, Transactions>();
        
        Iterator<Transactions> iter = transactions.iterator();
        while(iter.hasNext()){
            Transactions next = iter.next();
            map.put(next.getUniqueTransaction(), next);
        }
        
        return map;
    }

    public static Map<Integer, Departments> departmentsToMap(List<Departments> all) {
        Map<Integer, Departments> map = new HashMap<Integer, Departments>();
        
        Iterator<Departments> iter = all.iterator();
        while (iter.hasNext()) {
            Departments departments = iter.next();
            map.put(departments.getNumber(), departments);
        }
        
        return map;
    }

    public static Map<String, Products> productsToMap(List<Products> all) {
        Map<String, Products> map = new HashMap<String, Products>();
        
        Iterator<Products> iter = all.iterator();
        while (iter.hasNext()) {
            Products next = iter.next();
            map.put(next.getUpc(), next);
        }
        
        return map;
    }

    public static Map<String, Actions> actionsToMap(List<Actions> all) {
        Map<String, Actions> map = new HashMap<String, Actions>();
        
        Iterator<Actions> iter = all.iterator();
        while (iter.hasNext()) {
            Actions next = iter.next();
            map.put(next.getCode(), next);
        }
        
        return map;
    }

    public static Map<Integer, Registers> registersToMap(Set<Registers> registerses) {
        Map<Integer, Registers> map = new HashMap<Integer, Registers>();
        
        Iterator<Registers> iter = registerses.iterator();
        while (iter.hasNext()) {
            Registers next = iter.next();
            map.put(next.getNumber(), next);
        }
        
        return map;
    }

    public static Map<String, Cashiers> cashiersToMap(Set<Cashiers> cashierses) {
        Map<String, Cashiers> map = new HashMap<String, Cashiers>();
        
        Iterator<Cashiers> iter = cashierses.iterator();
        while (iter.hasNext()) {
            Cashiers next = iter.next();
            map.put(next.getCode(), next);
        }
        
        return map;
    }
}
